package com.guchenbo.flink;

import com.guchenbo.datagen.common.Person;
import org.apache.flink.streaming.api.datastream.DataStream;
import org.apache.flink.streaming.api.datastream.KeyedStream;
import org.apache.flink.streaming.api.environment.StreamExecutionEnvironment;

/**
 * @author guchenbo
 * @date 2024/6/10
 */
public class PersonStreamDemo {
    public static void main(String[] args) throws Exception {
        StreamExecutionEnvironment env = StreamExecutionEnvironment.getExecutionEnvironment();
        env.setParallelism(2);

        DataStream<Person> personDataStream = env.addSource(new PersonSource());
        KeyedStream<Person, String> keyedStream = personDataStream.keyBy(Person::getName);

        keyedStream.print();
        env.execute();
    }
}
